<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT distinct `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);
?>
<table border="0" width="800" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">&nbsp;</font><font face="Verdana" color="#224568">Block wise Percenatge of type of complaints received</font></span>
		<div align="center"><span style="font-size: 9pt; font-weight: 700">
	        <font face="Verdana" color="#224568"> Table 28</font></span></div>
		</td>
	</tr>
	<tr height="61">
		<td bgcolor="#E9E9E9" height="61">
		<table border="1" width="900" cellspacing="0" cellpadding="0" height="402">
			<tr bgcolor="#C5D8EB">
				
				<td width="152" height="37" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Name of the Block</font></td>
				<td width="120" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Type of schemes				</font></td>
				<td align="center" width="379">
				<font style="font-size: 8.5pt" face="Verdana">Type of Complaints</font></td>
				<td align="center" width="122">
				<font style="font-size: 8.5pt" face="Verdana">No. of Complaints</font></td>
				<td align="center">
				<font style="font-size: 8.5pt" face="Verdana">Percentage</font></td>
				
			</tr>
       <?php  	
         	
			//$numVillage=0;
			//$numFormVill=0;
			while($rowReport = mysql_fetch_array($queryReport)) {
			
			    
							 
				 $a1=getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'Piped');
				 $a2=getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'Piped');
				 $a3=getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'Piped');
				 $a4=getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'Piped');
				 $a5=getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'Piped');
				 $c1=$a1+$a2+$a3+$a4+$a5;
				
				 $a6=getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'TSS(P&T)');
				 $a7=getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'TSS(P&T)');
				 $a8=getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'TSS(P&T)');
				 $a9=getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'TSS(P&T)');
				 $a10=getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'TSS(P&T)');
				 $c2=$a6+$a7+$a8+$a9+$a10;
				 
				 $a11=getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'Sanitary Diggs');
				 $a12=getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'Sanitary Diggs');
				 $a13=getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'Sanitary Diggs');
				 $a14=getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'Sanitary Diggs');
				 $a15=getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'Sanitary Diggs');
				 $c3=$a11+$a12+$a13+$a14+$a15;
				 ?>  
				<tr bgcolor="#FFFFFF">
				
				<td width="152" align="center" rowspan="6"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name'];  ?></font></td>
				<td width="120" align="center" rowspan="6"><font style="font-size: 8.5pt" face="Verdana">Piped</font></td>
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Non supply of water due to power failure</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'Piped');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c1==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a1/$c1)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Poor water quality</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'Piped');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c1==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a2/$c1)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">absence of PHED staff</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'Piped');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c1==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a3/$c1)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Polluted source of drinking water</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'Piped');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c1==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a4/$c1)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">disruption in water supply due to poorly maintained water supply</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'Piped');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c1==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a5/$c1)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#E9E9E9">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				 
				echo $c1;
				?></font>				</td>
				<td align="center" width="115">&nbsp;</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				
				<td width="152" align="center" rowspan="6">&nbsp;</td>
				<td width="120" align="center" rowspan="6"><font style="font-size: 8.5pt" face="Verdana">P&T</font></td>
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Non supply of water due to power failure</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'TSS(P&T)');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c2==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a6/$c2)*100,2,'.','');
				}
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Poor water quality</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'TSS(P&T)');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c2==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a7/$c2)*100,2,'.','');
				}
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">absence of PHED staff</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'TSS(P&T)');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c2==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a8/$c2)*100,2,'.','');
				}
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Polluted source of drinking water</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'TSS(P&T)');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c2==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a9/$c2)*100,2,'.','');
				}
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">disruption in water supply due to poorly maintained water supply</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'P&T')+getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'TSS(P&T)');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c2==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a10/$c2)*100,2,'.','');
				}
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#E9E9E9">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				 
				echo $c2;
				?></font>				</td>
				<td align="center" width="115">&nbsp;</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				
				<td width="152" align="center" rowspan="6">&nbsp;</td>
				<td width="120" align="center" rowspan="6"><font style="font-size: 8.5pt" face="Verdana">Sanitary Diggs</font></td>
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Non supply of water due to power failure</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_1',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c3==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a11/$c3)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Poor water quality</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_2',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c3==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a12/$c3)*100,2,'.','');
				}				
				?>
				</font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">absence of PHED staff</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_3',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c3==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a13/$c3)*100,2,'.','');
				}				
				?>
				</font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Polluted source of drinking water</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_4',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c3==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a14/$c3)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#FFFFFF">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">disruption in water supply due to poorly maintained water supply</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo getcomplaint_for_scheme('complaint_5',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
				<td align="center" width="115"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($c3==0)
				{
				echo "0.00";
				}else{
				echo number_format(($a15/$c3)*100,2,'.','');
				}				
				?></font>				</td>
				
			</tr>
			<tr bgcolor="#E9E9E9">
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				echo $c3;
				?></font>				</td>
				<td align="center" width="115">&nbsp;</td>
				
			</tr>
			
			
				 <?php
				 $grand=$c1+$c2+$c3;
				 $grand_tot+=$grand;	
         	}
			?>	
			<tr bgcolor="#E9E9E9">
				<td align="center" width="115">&nbsp;</td>
				<td align="center" width="115">&nbsp;</td>
				<td width="379" align="left">
				<font style="font-size: 8.5pt" face="Verdana">Grand Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				echo $grand_tot;
				?></font>				</td>
				<td align="center" width="115">&nbsp;</td>
				
			</tr>
		
		  </table>
		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>